<?php
namespace Home\Controller;
use Think\Controller;
class UserController extends Controller {
    public function login(){
        $this->display();
    }
    public function register(){
        //$user = D('User');
        header('Content-type:text/html;charset=utf-8');
        $user =new \Model\UserModel();//如果调用模型中的方法 必须这样实例化model
        if(!empty($_POST)){
            //$_POST['user_hobby'] = implode(',', $_POST['user_hobby']);
            //$Z = $user -> add($_POST);
            //echo $z;
            $res = $user ->create();//收集表单信息自动验证
            if($res){
                //$z = $user->add($res);
                //echo $z;
                echo "success";
            } else {
                dump($user->getError());
            }
            
        } else {
            $this->display();
        }
        
    }
}